home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DriverServices.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  14.1 KB  |  436 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DriverServices.p
  3.  
  4.      Contains:    Driver Services Interfaces.
  5.  
  6.      Version:    Technology:    PowerSurge 1.0.2 and beyond (including Copland)
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT DriverServices;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __DRIVERSERVICES__}
  28. {$SETC __DRIVERSERVICES__ := 1}
  29.  
  30. {$I+}
  31. {$SETC DriverServicesIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __CONDITIONALMACROS__}
  35. {$I ConditionalMacros.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __ERRORS__}
  41. {$I Errors.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  44. {$I MachineExceptions.p}
  45. {$ENDC}
  46. {$IFC UNDEFINED __DEVICES__}
  47. {$I Devices.p}
  48. {$ENDC}
  49. {$IFC UNDEFINED __DRIVERSYNCHRONIZATION__}
  50. {$I DriverSynchronization.p}
  51. {$ENDC}
  52.  
  53.  
  54. {$PUSH}
  55. {$ALIGN POWER}
  56. {$LibExport+}
  57.  
  58. {*****************************************************************
  59.  *
  60.  *         Previously in Kernel.h
  61.  *
  62.  *****************************************************************}
  63. {  Kernel basics }
  64.  
  65. TYPE
  66.     IOPreparationID = ^LONGINT;
  67.     SoftwareInterruptID = ^LONGINT;
  68.     TaskID = ^LONGINT;
  69.     TimerID = ^LONGINT;
  70. {  OrderedItem stuff }
  71.     OrderedItemService                    = OSType;
  72.     OrderedItemSignature                = OSType;
  73.  
  74. CONST
  75.     kMatchAnyOrderedItemService    = '****';
  76.     kMatchAnyOrderedItemSignature = '****';
  77.     kDoNotMatchAnyOrderedItemService = '----';
  78.     kDoNotMatchAnyOrderedItemSignature = '----';
  79.  
  80.  
  81. TYPE
  82.     OrderedItemNamePtr = ^OrderedItemName;
  83.     OrderedItemName = RECORD
  84.         service:                OrderedItemService;
  85.         signature:                OrderedItemSignature;
  86.     END;
  87.  
  88.     OrderedItemOptions                    = OptionBits;
  89.  
  90. CONST
  91.     kOrderedItemIsRightBefore    = $00000001;
  92.     kOrderedItemIsRightAfter    = $00000002;
  93.  
  94.  
  95. TYPE
  96.     OrderRequirementsPtr = ^OrderRequirements;
  97.     OrderRequirements = RECORD
  98.         options:                OrderedItemOptions;
  99.         itemBefore:                OrderedItemName;
  100.         itemAfter:                OrderedItemName;
  101.     END;
  102.  
  103. {  Tasking }
  104.     ExecutionLevel                        = UInt32;
  105.  
  106. CONST
  107.     kTaskLevel                    = 0;
  108.     kSoftwareInterruptLevel        = 1;
  109.     kAcceptFunctionLevel        = 2;
  110.     kKernelLevel                = 3;
  111.     kSIHAcceptFunctionLevel        = 4;
  112.     kSecondaryInterruptLevel    = 5;
  113.     kHardwareInterruptLevel        = 6;
  114.  
  115.  
  116. TYPE
  117.     SoftwareInterruptHandler = ProcPtr;  { PROCEDURE SoftwareInterruptHandler(p1: UNIV Ptr; p2: UNIV Ptr); C; }
  118.  
  119.     SecondaryInterruptHandler2 = ProcPtr;  { FUNCTION SecondaryInterruptHandler2(p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C; }
  120.  
  121.  
  122. CONST
  123.     kCurrentAddressSpaceID        = -1;
  124.  
  125.  
  126. {  Memory System basics }
  127.  
  128. TYPE
  129.     LogicalAddressRangePtr = ^LogicalAddressRange;
  130.     LogicalAddressRange = RECORD
  131.         address:                LogicalAddress;
  132.         count:                    ByteCount;
  133.     END;
  134.  
  135.     PhysicalAddressRangePtr = ^PhysicalAddressRange;
  136.     PhysicalAddressRange = RECORD
  137.         address:                PhysicalAddress;
  138.         count:                    ByteCount;
  139.     END;
  140.  
  141. {  For PrepareMemoryForIO and CheckpointIO }
  142.     IOPreparationOptions                = OptionBits;
  143.  
  144. CONST
  145.     kIOMultipleRanges            = $00000001;
  146.     kIOLogicalRanges            = $00000002;
  147.     kIOMinimalLogicalMapping    = $00000004;
  148.     kIOShareMappingTables        = $00000008;
  149.     kIOIsInput                    = $00000010;
  150.     kIOIsOutput                    = $00000020;
  151.     kIOCoherentDataPath            = $00000040;
  152.     kIOTransferIsLogical        = $00000080;
  153.     kIOClientIsUserMode            = $00000080;
  154.  
  155.  
  156. TYPE
  157.     IOPreparationState                    = OptionBits;
  158.  
  159. CONST
  160.     kIOStateDone                = $00000001;
  161.  
  162.     kInvalidPageAddress            = -1;
  163.  
  164.  
  165. TYPE
  166.     AddressRangePtr = ^AddressRange;
  167.     AddressRange = RECORD
  168.         base:                    Ptr;
  169.         length:                    ByteCount;
  170.     END;
  171.  
  172. {  C's treatment of arrays and array pointers is atypical }
  173.     LogicalMappingTable                    = ARRAY [0..0] OF LogicalAddress;
  174.     LogicalMappingTablePtr                = ^LogicalMappingTable;
  175.     PhysicalMappingTable                = ARRAY [0..0] OF PhysicalAddress;
  176.     PhysicalMappingTablePtr                = ^PhysicalMappingTable;
  177.     AddressRangeTable                    = ARRAY [0..0] OF AddressRange;
  178.     AddressRangeTablePtr                = ^AddressRangeTable;
  179.     MultipleAddressRangePtr = ^MultipleAddressRange;
  180.     MultipleAddressRange = RECORD
  181.         entryCount:                ItemCount;
  182.         rangeTable:                AddressRangeTablePtr;
  183.     END;
  184.  
  185. {
  186.    Separate C definition so that union has a name.  A future version of the interfacer
  187.    tool will allow a name (that gets thrown out in Pascal and Asm).
  188. }
  189.     IOPreparationTablePtr = ^IOPreparationTable;
  190.     IOPreparationTable = RECORD
  191.         options:                IOPreparationOptions;
  192.         state:                    IOPreparationState;
  193.         preparationID:            IOPreparationID;
  194.         addressSpace:            AddressSpaceID;
  195.         granularity:            ByteCount;
  196.         firstPrepared:            ByteCount;
  197.         lengthPrepared:            ByteCount;
  198.         mappingEntryCount:        ItemCount;
  199.         logicalMapping:            LogicalMappingTablePtr;
  200.         physicalMapping:        PhysicalMappingTablePtr;
  201.         CASE INTEGER OF
  202.         0: (
  203.             range:                AddressRange;
  204.             );
  205.         1: (
  206.             multipleRanges:        MultipleAddressRange;
  207.             );
  208.     END;
  209.  
  210.     IOCheckpointOptions                    = OptionBits;
  211.  
  212. CONST
  213.     kNextIOIsInput                = $00000001;
  214.     kNextIOIsOutput                = $00000002;
  215.     kMoreIOTransfers            = $00000004;
  216.  
  217. {  For SetProcessorCacheMode }
  218.  
  219.  
  220. TYPE
  221.     ProcessorCacheMode                    = UInt32;
  222.  
  223. CONST
  224.     kProcessorCacheModeDefault    = 0;
  225.     kProcessorCacheModeInhibited = 1;
  226.     kProcessorCacheModeWriteThrough = 2;
  227.     kProcessorCacheModeCopyBack    = 3;
  228.  
  229. {  For GetPageInformation }
  230.  
  231.     kPageInformationVersion        = 1;
  232.  
  233.  
  234. TYPE
  235.     PageStateInformation                = UInt32;
  236.  
  237. CONST
  238.     kPageIsProtected            = $00000001;
  239.     kPageIsProtectedPrivileged    = $00000002;
  240.     kPageIsModified                = $00000004;
  241.     kPageIsReferenced            = $00000008;
  242.     kPageIsLockedResident        = $00000010;
  243.     kPageIsInMemory                = $00000020;
  244.     kPageIsShared                = $00000040;
  245.     kPageIsWriteThroughCached    = $00000080;
  246.     kPageIsCopyBackCached        = $00000100;
  247.     kPageIsLocked                = $00000010;                    {  Deprecated }
  248.     kPageIsResident                = $00000020;                    {  Deprecated }
  249.  
  250.  
  251. TYPE
  252.     PageInformationPtr = ^PageInformation;
  253.     PageInformation = RECORD
  254.         area:                    AreaID;
  255.         count:                    ItemCount;
  256.         information:            ARRAY [0..0] OF PageStateInformation;
  257.     END;
  258.  
  259.  
  260. {  Tasks  }
  261. FUNCTION CurrentExecutionLevel: ExecutionLevel; C;
  262. FUNCTION CurrentTaskID: TaskID; C;
  263. FUNCTION DelayFor(delayDuration: Duration): OSStatus; C;
  264. FUNCTION InPrivilegedMode: BOOLEAN; C;
  265.  
  266. {  Software Interrupts  }
  267. FUNCTION CreateSoftwareInterrupt(handler: SoftwareInterruptHandler; task: TaskID; p1: UNIV Ptr; persistent: BOOLEAN; VAR theSoftwareInterrupt: SoftwareInterruptID): OSStatus; C;
  268.  
  269. FUNCTION SendSoftwareInterrupt(theSoftwareInterrupt: SoftwareInterruptID; p2: UNIV Ptr): OSStatus; C;
  270. FUNCTION DeleteSoftwareInterrupt(theSoftwareInterrupt: SoftwareInterruptID): OSStatus; C;
  271. {  Secondary Interrupts  }
  272. FUNCTION CallSecondaryInterruptHandler2(theHandler: SecondaryInterruptHandler2; exceptionHandler: ExceptionHandler; p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C;
  273. FUNCTION QueueSecondaryInterruptHandler(theHandler: SecondaryInterruptHandler2; exceptionHandler: ExceptionHandler; p1: UNIV Ptr; p2: UNIV Ptr): OSStatus; C;
  274.  
  275. {  Timers  }
  276. FUNCTION SetInterruptTimer({CONST}VAR expirationTime: AbsoluteTime; handler: SecondaryInterruptHandler2; p1: UNIV Ptr; VAR theTimer: TimerID): OSStatus; C;
  277. FUNCTION CancelTimer(theTimer: TimerID; VAR timeRemaining: AbsoluteTime): OSStatus; C;
  278.  
  279. {  I/O related Operations  }
  280. FUNCTION PrepareMemoryForIO(VAR theIOPreparationTable: IOPreparationTable): OSStatus; C;
  281. FUNCTION CheckpointIO(theIOPreparation: IOPreparationID; options: IOCheckpointOptions): OSStatus; C;
  282.  
  283. {  Memory Operations  }
  284. FUNCTION GetPageInformation(addressSpace: AddressSpaceID; base: ConstLogicalAddress; requestedPages: ItemCount; version: PBVersion; VAR thePageInfo: PageInformation): OSStatus; C;
  285. {  Processor Cache Related  }
  286. FUNCTION SetProcessorCacheMode(addressSpace: AddressSpaceID; base: ConstLogicalAddress; length: ByteCount; cacheMode: ProcessorCacheMode): OSStatus; C;
  287. {*****************************************************************
  288.  *
  289.  *         Was in DriverSupport.h or DriverServices.h
  290.  *
  291.  *****************************************************************}
  292.  
  293. TYPE
  294.     DeviceLogicalAddressPtr                = ^LogicalAddress;
  295.  
  296. CONST
  297.     durationMicrosecond            = -1;                            {  Microseconds are negative }
  298.     durationMillisecond            = 1;                            {  Milliseconds are positive }
  299.     durationSecond                = 1000;                            {  1000 * durationMillisecond }
  300.     durationMinute                = 60000;                        {  60 * durationSecond, }
  301.     durationHour                = 3600000;                        {  60 * durationMinute, }
  302.     durationDay                    = 86400000;                        {  24 * durationHour, }
  303.     durationNoWait                = 0;                            {  don't block }
  304.     durationForever                = $7FFFFFFF;                    {  no time limit }
  305.  
  306.     k8BitAccess                    = 0;                            {  access as 8 bit }
  307.     k16BitAccess                = 1;                            {  access as 16 bit }
  308.     k32BitAccess                = 2;                            {  access as 32 bit }
  309.  
  310.  
  311. TYPE
  312.     Nanoseconds                            = UnsignedWide;
  313.     NanosecondsPtr                         = ^Nanoseconds;
  314.  
  315. FUNCTION IOCommandIsComplete(theID: IOCommandID; theResult: OSErr): OSErr; C;
  316. FUNCTION GetIOCommandInfo(theID: IOCommandID; VAR theContents: IOCommandContents; VAR theCommand: IOCommandCode; VAR theKind: IOCommandKind): OSErr; C;
  317. PROCEDURE UpdateDeviceActivity(VAR deviceEntry: RegEntryID); C;
  318. PROCEDURE BlockCopy(srcPtr: UNIV Ptr; destPtr: UNIV Ptr; byteCount: Size); C;
  319. FUNCTION PoolAllocateResident(byteSize: ByteCount; clear: BOOLEAN): LogicalAddress; C;
  320. FUNCTION PoolDeallocate(address: LogicalAddress): OSStatus; C;
  321. FUNCTION GetLogicalPageSize: ByteCount; C;
  322. FUNCTION GetDataCacheLineSize: ByteCount; C;
  323. FUNCTION FlushProcessorCache(spaceID: AddressSpaceID; base: LogicalAddress; length: ByteCount): OSStatus; C;
  324. FUNCTION MemAllocatePhysicallyContiguous(byteSize: ByteCount; clear: BOOLEAN): LogicalAddress; C;
  325. FUNCTION MemDeallocatePhysicallyContiguous(address: LogicalAddress): OSStatus; C;
  326.  
  327. FUNCTION UpTime: AbsoluteTime; C;
  328. PROCEDURE GetTimeBaseInfo(VAR minAbsoluteTimeDelta: UInt32; VAR theAbsoluteTimeToNanosecondNumerator: UInt32; VAR theAbsoluteTimeToNanosecondDenominator: UInt32; VAR theProcessorToAbsoluteTimeNumerator: UInt32; VAR theProcessorToAbsoluteTimeDenominator: UInt32); C;
  329.  
  330. FUNCTION AbsoluteToNanoseconds(absoluteTime: AbsoluteTime): Nanoseconds; C;
  331. FUNCTION AbsoluteToDuration(absoluteTime: AbsoluteTime): Duration; C;
  332. FUNCTION NanosecondsToAbsolute(nanoseconds: Nanoseconds): AbsoluteTime; C;
  333. FUNCTION DurationToAbsolute(duration: Duration): AbsoluteTime; C;
  334. FUNCTION AddAbsoluteToAbsolute(absoluteTime1: AbsoluteTime; absoluteTime2: AbsoluteTime): AbsoluteTime; C;
  335. FUNCTION SubAbsoluteFromAbsolute(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): AbsoluteTime; C;
  336. FUNCTION AddNanosecondsToAbsolute(nanoseconds: Nanoseconds; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  337. FUNCTION AddDurationToAbsolute(duration: Duration; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  338. FUNCTION SubNanosecondsFromAbsolute(nanoseconds: Nanoseconds; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  339. FUNCTION SubDurationFromAbsolute(duration: Duration; absoluteTime: AbsoluteTime): AbsoluteTime; C;
  340. FUNCTION AbsoluteDeltaToNanoseconds(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): Nanoseconds; C;
  341. FUNCTION AbsoluteDeltaToDuration(leftAbsoluteTime: AbsoluteTime; rightAbsoluteTime: AbsoluteTime): Duration; C;
  342. FUNCTION DurationToNanoseconds(theDuration: Duration): Nanoseconds; C;
  343. FUNCTION NanosecondsToDuration(theNanoseconds: Nanoseconds): Duration; C;
  344.  
  345. FUNCTION PBQueueInit(qHeader: QHdrPtr): OSErr; C;
  346. FUNCTION PBQueueCreate(VAR qHeader: QHdrPtr): OSErr; C;
  347. FUNCTION PBQueueDelete(qHeader: QHdrPtr): OSErr; C;
  348. PROCEDURE PBEnqueue(qElement: QElemPtr; qHeader: QHdrPtr); C;
  349. FUNCTION PBEnqueueLast(qElement: QElemPtr; qHeader: QHdrPtr): OSErr; C;
  350. FUNCTION PBDequeue(qElement: QElemPtr; qHeader: QHdrPtr): OSErr; C;
  351. FUNCTION PBDequeueFirst(qHeader: QHdrPtr; VAR theFirstqElem: QElemPtr): OSErr; C;
  352. FUNCTION PBDequeueLast(qHeader: QHdrPtr; VAR theLastqElem: QElemPtr): OSErr; C;
  353. FUNCTION DeviceProbe(theSrc: UNIV Ptr; theDest: UNIV Ptr; AccessType: UInt32): OSStatus; C;
  354. FUNCTION DelayForHardware(absoluteTime: AbsoluteTime): OSStatus; C;
  355.  
  356.  
  357. {*****************************************************************
  358.  *
  359.  *         Was in Interrupts.h 
  360.  *
  361.  *****************************************************************}
  362. {  Interrupt types  }
  363.  
  364. TYPE
  365.     InterruptSetID = ^LONGINT;
  366.     InterruptMemberNumber                = LONGINT;
  367.     InterruptSetMemberPtr = ^InterruptSetMember;
  368.     InterruptSetMember = RECORD
  369.         setID:                    InterruptSetID;
  370.         member:                    InterruptMemberNumber;
  371.     END;
  372.  
  373.  
  374. CONST
  375.     kISTChipInterruptSource        = 0;
  376.     kISTOutputDMAInterruptSource = 1;
  377.     kISTInputDMAInterruptSource    = 2;
  378.     kISTPropertyMemberCount        = 3;
  379.  
  380.  
  381. TYPE
  382.     ISTProperty                            = ARRAY [0..2] OF InterruptSetMember;
  383.     InterruptReturnValue                = LONGINT;
  384.  
  385. CONST
  386.     kFirstMemberNumber            = 1;
  387.     kIsrIsComplete                = 0;
  388.     kIsrIsNotComplete            = -1;
  389.     kMemberNumberParent            = -2;
  390.  
  391.  
  392. TYPE
  393.     InterruptSourceState                = BOOLEAN;
  394.  
  395. CONST
  396.     kSourceWasEnabled            = 1;
  397.     kSourceWasDisabled            = 0;
  398.  
  399.  
  400.  
  401. TYPE
  402.     InterruptHandler = ProcPtr;  { FUNCTION InterruptHandler(ISTmember: InterruptSetMember; refCon: UNIV Ptr; theIntCount: UInt32): InterruptMemberNumber; C; }
  403.  
  404.     InterruptEnabler = ProcPtr;  { PROCEDURE InterruptEnabler(ISTmember: InterruptSetMember; refCon: UNIV Ptr); C; }
  405.  
  406.     InterruptDisabler = ProcPtr;  { FUNCTION InterruptDisabler(ISTmember: InterruptSetMember; refCon: UNIV Ptr): ByteParameter; C; }
  407.  
  408.  
  409. CONST
  410.     kReturnToParentWhenComplete    = $00000001;
  411.     kReturnToParentWhenNotComplete = $00000002;
  412.  
  413.  
  414. TYPE
  415.     InterruptSetOptions                    = OptionBits;
  416. {  Interrupt Services  }
  417. FUNCTION CreateInterruptSet(parentSet: InterruptSetID; parentMember: InterruptMemberNumber; setSize: InterruptMemberNumber; VAR setID: InterruptSetID; options: InterruptSetOptions): OSStatus; C;
  418.  
  419. FUNCTION InstallInterruptFunctions(setID: InterruptSetID; member: InterruptMemberNumber; refCon: UNIV Ptr; handlerFunction: InterruptHandler; enableFunction: InterruptEnabler; disableFunction: InterruptDisabler): OSStatus; C;
  420.  
  421. FUNCTION GetInterruptFunctions(setID: InterruptSetID; member: InterruptMemberNumber; VAR refCon: UNIV Ptr; VAR handlerFunction: InterruptHandler; VAR enableFunction: InterruptEnabler; VAR disableFunction: InterruptDisabler): OSStatus; C;
  422. FUNCTION ChangeInterruptSetOptions(setID: InterruptSetID; options: InterruptSetOptions): OSStatus; C;
  423. FUNCTION GetInterruptSetOptions(setID: InterruptSetID; VAR options: InterruptSetOptions): OSStatus; C;
  424.  
  425.  
  426. {$ALIGN RESET}
  427. {$POP}
  428.  
  429. {$SETC UsingIncludes := DriverServicesIncludes}
  430.  
  431. {$ENDC} {__DRIVERSERVICES__}
  432.  
  433. {$IFC NOT UsingIncludes}
  434.  END.
  435. {$ENDC}
  436.